package com.zimin.cloud.wiki.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zimin.cloud.mine.pojo.wiki.business.CategoryBO;
import com.zimin.cloud.mine.pojo.wiki.view.CategoryVO;
import com.zimin.cloud.wiki.biz.ICategoryBiz;
import com.zimin.cloud.wiki.controller.api.ICategoryController;
import com.zimin.cloud.wiki.pojo.entity.Category;
import com.zimin.shared.pojo.PageVO;
import com.zimin.shared.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import com.zimin.shared.pojo.BaseController;

import java.util.List;

/**
 * <p>
 * 分类 前端控制器
 * </p>
 *
 * @author zimin
 * @since 2021-10-27 21:02
 */
@RestController
public class CategoryController extends BaseController implements ICategoryController {

    @Autowired
    private ICategoryBiz categoryBiz;

    @Override
    public Result categoryList(Page page, CategoryBO categoryBO) {
        PageVO<CategoryVO> categoryVOList = categoryBiz.list(page, categoryBO);
        return Result.ok(categoryVOList);
    }

    @Override
    public Result saveCategory(CategoryBO categoryBO) {
        return result(categoryBiz.save(categoryBO));
    }

    @Override
    public Result updateCategory(CategoryBO categoryBO) {
        return result(categoryBiz.updateById(categoryBO));
    }

    @Override
    public Result removeById(String id) {
        return result(categoryBiz.removeById(id));
    }

    @Override
    public Result categoryAll(CategoryBO categoryBO) {
        List<CategoryVO> categoryVOList = categoryBiz.allTree(categoryBO);
        return Result.ok(categoryVOList);
    }
}
